define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form,) {
    var Controller = {
        index: function () {
            $(".btn-add").data("area", ["100%", "100%"]); //添加
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'lists/one/index' + location.search,
                    add_url: 'lists/one/add',
                    edit_url: 'lists/one/edit',
                    del_url: 'lists/one/del',
                    multi_url: 'lists/one/multi',
                    import_url: 'lists/one/import',
                    table: 'list_one',
                }
            });
            var table = $("#table");

            table.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                // console.log(data);
                //这里我们手动设置底部的值
                $("#all_main_free").text(data.all_main_free);
                $("#all_main_sum").text(data.all_main_sum);
            });
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                search: false,
                columns: [
                    [
                        // {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        {
                            field: 'status',
                            title: __('状态'),
                            operate: false,
                            formatter: function (value, row, index) {
                                // console.log('index',row)
                                var html = '';
                                if (!row.tong_number) {
                                    html = "<p style=\"color:#32f800;font-weight: 700;border: 1px solid #32f800;border-radius: 4px;width: 29px;height: 22px;line-height: 20px;text-align: center;display: inline-block;margin: 0;\">\n" +
                                        "                        暂存</p>";
                                } else {
                                    if (row.status == 6) {
                                        html = "<p style=\"color:#fa0b0b;font-weight: 700;border: 1px solid #fa0b0b;border-radius: 4px;width: 29px;height: 22px;line-height: 20px;text-align: center;display: inline-block;margin: 0;\">\n" +
                                            "                        退统</p>";
                                    } else if (row.status == 7) {
                                        html = "<p style=\"color:#fa0b0b;font-weight: 700;border: 1px solid #fa0b0b;border-radius: 4px;width: 29px;height: 22px;line-height: 20px;text-align: center;display: inline-block;margin: 0;\">\n" +
                                            "                        作废</p>";
                                    } else {
                                        html = " <p style=\"color:#000;font-weight: 700;border: 1px solid #000;border-radius: 4px;width: 29px;height: 22px;line-height: 20px;text-align: center;display: inline-block;margin: 0;\">\n" +
                                            "                        正常</p>";
                                    }
                                }
                                return html;
                            }
                        },
                        {
                            field: 'tong_storage',
                            title: __('暂存单号'),
                            operate: 'LIKE',
                            table: table,
                            class: 'autocontent',
                            formatter: function (value, row, index) {
                                if (value) {
                                    return value;
                                } else {
                                    return '-';
                                }
                            }
                        },
                        {
                            field: 'tong_number',
                            title: __('服务单号'),
                            operate: 'LIKE',
                            table: table,
                            class: 'autocontent',
                            formatter: function (value, row, index) {
                                if (value) {
                                    return value;
                                } else {
                                    return '-';
                                }
                            }
                        },
                        {
                            field: 'zuzhi.name',
                            title: __('组织'),
                            searchList: $.getJSON('lists/one/select_zuzhi'),
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'car_num',
                            title: __('车牌号'),
                            operate: 'LIKE',
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'car_vin',
                            title: __('车架号'),
                            operate: 'LIKE',
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'car_engine',
                            title: __('发动机号'),
                            visible: false,
                            operate: 'LIKE',
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'learned_name',
                            title: __('被服务人'),
                            operate: 'LIKE',
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'yw_join_time',
                            title: __('服务日期'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'yw_hetong_time',
                            title: __('审核日期'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'plan_strattime',
                            title: __('服务起期'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'plan_endtime',
                            title: __('服务止期'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'car_register',
                            title: __('初登时间'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },


                        //
                        // {
                        //     field: 'main_sum',
                        //     title: __('标准服务费'),
                        //     operate: false,
                        //     visible: Config.zdstatus,
                        //     table: table,
                        //     class: 'autocontent',
                        //     formatter: Table.api.formatter.content
                        // },
                        // {
                        //     field: 'main_sumdiscount',
                        //     title: __('政策折扣(%)'),
                        //     operate: false,
                        //     visible: Config.zdstatus,
                        //     table: table,
                        //     class: 'autocontent',
                        //     formatter: Table.api.formatter.content
                        // },
                        {
                            field: 'main_free',
                            title: __('应缴服务费'),
                            operate: false,
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'yw_enter_peo',
                            title: __('录入人'),
                            operate: Config.sxstatus,
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'yw_hetongpeo',
                            title: __('审核人'),
                            operate: Config.sxstatus,
                            table: table,
                            class: 'autocontent',
                            formatter: function (value, row, index) {
                                if (value) {
                                    return value;
                                } else {
                                    return '-';
                                }
                            }
                        },
                        // {
                        //     field: 'yw_belonger',
                        //     title: __('归属人'),
                        //     operate: Config.sxstatus,
                        //     table: table,
                        //     class: 'autocontent',
                        //     formatter: Table.api.formatter.content
                        // },
                        {
                            field: 'pay_fangshi',
                            title: __('支付方式'),
                            operate: Config.sxstatus,
                            table: table,
                            class: 'autocontent',
                            formatter: function (value, row, index) {
                                if (value) {
                                    return value;
                                } else {
                                    return '-';
                                }
                            }
                        },

                        {
                            field: 'sign',
                            title: __('签字状态'),
                            operate: false,
                            visible: Config.status,
                            table: table,
                            class: 'autocontent',
                            formatter: function (value, row, index) {
                                if (value == 1) {
                                    var html = "已签字(<span style='color:red;cursor:pointer' onclick='qianzi(" + row.id + "," + row.gs_type + ")'>重新签字</span>)";
                                    return html;
                                } else {
                                    var html = "<span onclick='copaylink(" + row.id + "," + row.gs_type + ")'>点击复制签字链接</span>";
                                    return html;
                                }
                            }
                        },
                        {
                            field: 'status',
                            title: __('状态'),
                            searchList: {
                                0: __('暂存'),
                                1: __('待审核'),
                                2: __('待市级审核'),
                                3: __('审核通过待缴费'),
                                4: __('待修改'),
                                5: __('已出单'),
                                6: __('已退统'),
                                7: __('已过期'),
                            },
                            custom: {
                                0: 'success',
                                1: 'default',
                                2: 'warning',
                                3: 'info',
                                4: 'danger',
                                5: 'primary',
                                6: 'huang',
                                7: 'zi'
                            },
                            formatter: Table.api.formatter.label
                        },
                        {
                            field: 'car_factory_num',
                            title: __('厂牌型号'),
                            // visible: false,
                            operate: false,
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'chexing',
                            title: __('车型'),
                            searchList:$.getJSON('lists/one/chexing'),
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            // formatter: Table.api.formatter.operate,
                            formatter: function (value, row, index) {
                                var that = $.extend({}, this);
                                var table = $(that.table).clone(true);
                                // operate-edit编辑  perate-del删除
                                //判断什么时候显示什么时候不显示
                                // if (row.status === 1) {
                                //     $(table).data("operate-del", null); // 列表页面隐藏 .编辑operate-edit  - 删除按钮operate-del
                                //     // $(table).data("operate-edit", null); // 列表页面隐藏 .编辑operate-edit  - 删除按钮operate-del
                                // }
                                that.table = table;
                                return Table.api.formatter.operate.call(that, value, row, index);
                            },
                            buttons: [
                                {
                                    name: 'details',
                                    text: '浏览',
                                    classname: 'btn btn-info btn-xs btn-dialog',
                                    icon: '',
                                    url: 'lists/one/details',
                                    extend: 'data-area=["100%","100%"]',
                                    visible: function (row) {
                                        //权限判断
                                        if (Config.rule.includes('198') || Config.rule.includes(198)) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        }
                                    }
                                },
                                {
                                    name: 'edit',
                                    text: __('编辑'), // 按钮文字，语言在对应的lang文件设置
                                    title: __('编辑'), // 提示
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: '', // 更换图标
                                    url: 'lists/one/edit',
                                    extend: 'data-area=["100%","100%"]',
                                    visible: function (row) {
                                        //权限判断
                                        if (Config.rule.includes('105') || Config.rule.includes(105)) {
                                            //返回true时按钮显示,返回false隐藏
                                            if (row.status == 0 || row.status == 4) {
                                                return true;
                                            }
                                        }
                                    }
                                },
                                {
                                    name: 'del',
                                    text: __('删除'), // 按钮文字，语言在对应的lang文件设置
                                    title: __('删除'), // 提示
                                    classname: 'btn btn-xs btn-danger btn-ajax',
                                    icon: '', // 更换图标
                                    url: 'lists/one/del',
                                    confirm: '确认删除吗？',
                                    success: function (data, ret) {
                                        table.bootstrapTable('refresh');
                                    },
                                    visible: function (row) {
                                        //权限判断
                                        if (Config.rule.includes('106') || Config.rule.includes(106)) {
                                            //返回true时按钮显示,返回false隐藏
                                            if (row.status == 0 || row.status == 4) {
                                                return true;
                                            }
                                        }
                                    }
                                }, {
                                    name: 'ajax',
                                    text: __('驳回'),
                                    title: __('驳回'),
                                    classname: 'btn btn-xs btn-warning btn-magic btn-ajax',
                                    icon: '',
                                    confirm: '确定驳回？',
                                    url: 'lists/one/quxiao_admin',
                                    refresh: true,
                                    visible: function (row) {
                                        //权限判断
                                        if (Config.rule.includes('193') || Config.rule.includes(193)) {
                                            //返回true时按钮显示,返回false隐藏
                                            if (row.status != 0 && row.status != 4 && row.status != 7 && row.status != 6) {
                                                return true;
                                            }
                                        }

                                    },
                                    success: function (data, ret) {
                                        Layer.alert('驳回成功');
                                        table.bootstrapTable('refresh')
                                        //如果需要阻止成功提示，则必须使用return false;
                                        // return false;
                                    },
                                    error: function (data, ret) {
                                        // console.log(data, ret);
                                        Layer.alert(ret.msg);
                                        return false;
                                    },
                                }, {
                                    name: 'ajax',
                                    text: __('撤回'),
                                    title: __('撤回'),
                                    classname: 'btn btn-xs btn-primary btn-magic btn-ajax',
                                    icon: '',
                                    confirm: '确定撤回？',
                                    url: 'lists/one/quxiao',
                                    refresh: true,
                                    visible: function (row) {
                                        //权限判断
                                        if (Config.rule.includes('196') || Config.rule.includes(196)) {
                                            //返回true时按钮显示,返回false隐藏
                                            if (row.status == 1) {
                                                return true;
                                            }
                                        }
                                    },
                                    success: function (data, ret) {
                                        Layer.alert('撤回成功');
                                        table.bootstrapTable('refresh')
                                        //如果需要阻止成功提示，则必须使用return false;
                                        // return false;
                                    },
                                    error: function (data, ret) {
                                        // console.log(data, ret);
                                        Layer.alert(ret.msg);
                                        return false;
                                    },
                                },
                                {
                                    name: 'click',
                                    text: __('报价单'),
                                    title: __('报价单'),
                                    classname: 'btn btn-xs btn-info btn-click',
                                    icon: '',
                                    visible: function (row) {
                                        //权限判断
                                        if (Config.rule.includes('191') || Config.rule.includes(191)) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        }
                                    },
                                    click: function (data, row) {
                                        baojia(row.id)
                                    }
                                }, {
                                    name: 'addtabs',
                                    text: __('电子服务单'),
                                    title: __('电子服务单'),
                                    classname: 'btn btn-xs btn-warning btn-addtabs',
                                    icon: '',
                                    url: 'lists/one/dian',
                                    visible: function (row) {
                                        //权限判断
                                        if (Config.rule.includes('189') || Config.rule.includes(189)) {
                                            //返回true时按钮显示,返回false隐藏
                                            if (row.status == 5) {
                                                return true;
                                            }
                                        }
                                    }
                                },
                                {
                                    name: 'ajax',
                                    text: __('更新单号'),
                                    title: __('更新单号'),
                                    classname: 'btn btn-xs btn-success btn-magic btn-ajax',
                                    icon: '',
                                    confirm: '确定更新单号？',
                                    url: 'lists/one/up_danahao',
                                    refresh: true,
                                    visible: function (row) {
                                        //权限判断
                                        if (Config.rule.includes('192') || Config.rule.includes(192)) {
                                            //返回true时按钮显示,返回false隐藏
                                            if (row.status != 5) {
                                                return true;
                                            }
                                        }
                                    },
                                    success: function (data, ret) {
                                        Layer.alert('更新成功');
                                        table.bootstrapTable('refresh')
                                        //如果需要阻止成功提示，则必须使用return false;
                                        // return false;
                                    },
                                    error: function (data, ret) {
                                        console.log(data, ret);
                                        Layer.alert(ret.msg);
                                        return false;
                                    }
                                }, {
                                    name: 'edit',
                                    text: __('补录照片'), // 按钮文字，语言在对应的lang文件设置
                                    title: __('补录照片'), // 提示
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: '', // 更换图标
                                    url: 'lists/one/bulu',
                                    extend: 'data-area=["100%","100%"]',
                                    visible: function (row) {
                                        //权限判断
                                        if (Config.rule.includes('197') || Config.rule.includes(197)) {
                                            //返回true时按钮显示,返回false隐藏
                                            // if (row.status == 0 || row.status == 4) {
                                            return true;
                                            // }
                                        }
                                    }
                                }, {
                                    name: 'click',
                                    text: __('缴费'),
                                    title: __('缴费'),
                                    classname: 'btn btn-xs btn-info btn-click',
                                    icon: '',
                                    visible: function (row) {
                                        //权限判断
                                        if (Config.rule.includes('190') || Config.rule.includes(190)) {
                                            //返回true时按钮显示,返回false隐藏
                                            if (row.status == 3 || row.status == 6) {
                                                return true;
                                            }
                                        }


                                    },
                                    click: function (data, row) {
                                        jiaofei(row.id)
                                        newjiaofei(row.id, row.type, row.type)
                                    }
                                }
                            ]
                        }
                    ]
                ]
            });

            // 报价单
            function baojia(id) {
                $.ajax({
                    url: "lists/one/baojiadan",
                    dataType: 'json',
                    type: 'post',
                    data: {'id': id, 'lei': 1},
                    success: function (res) {
                        console.log('车牌号', res.data.car_num)//
                        $("#car_numm").html(res.data.car_num)//车牌号码
                        $("#car_owner").html(res.data.car_owner)//被服务人
                        $("#car_carry_peo").html(res.data.car_carry_peo)//核定载客量
                        $("#car_carry_quality").html(res.data.car_carry_quality)//核定载质量

                        var chexing = res.data.chexing;

                        if (chexing == "网约车") {
                            chexing = "网约或出租";
                        }

                        if (chexing == "2吨以下") {
                            chexing = "2吨以下货车";
                        }

                        if (chexing == "6座以下") {
                            chexing = "6座以下(私家车)";
                        }
                        if (chexing == "6-10座") {
                            chexing = "6-10座(私家车)";
                        }
                        if (chexing == "货车") {
                            chexing = "2吨以上货车";
                        }
                        console.log('chexing', res.data.car_use_natures)
                        $("#chexingg").html(chexing)//车型：
                        $("#learned_namee").html(res.data.car_use_natures)//使用性质

                        $("#chejiahao").html(res.data.car_vin)//车架号：
                        $("#fadongji").html(res.data.car_engine)//发动机号：

                        if (res.data.ncd == '新车') {
                            var ncd = '新车(含车损)'
                        } else if (res.data.ncd == '0次') {
                            var ncd = '0次(含车损)'
                        } else if (res.data.ncd == '出险1次') {
                            var ncd = '出险1次(含车损)'
                        } else if (res.data.ncd == '出险2次') {
                            var ncd = '出险2次(含车损)'
                        } else if (res.data.ncd == '出险3次') {
                            var ncd = '出险3次(含车损)'
                        } else if (res.data.ncd == '出险3次以上') {
                            var ncd = '出险3次以上(含车损)'
                        } else {
                            var ncd = res.data.ncd
                        }
                        $("#car_lastyear").html(ncd)//上年保险公司出险次数
                        var car_check = res.data.chexing;
                        $("#car_registerr").html(res.data.car_register)
                        $("#car_factory_num").html(res.data.car_factory_num)
                        $("#car_check_res").html(car_check)//验车提示：
                        $("#plan_strattime").html("自" + res.data.plan_strattime + " 起至 " + res.data.plan_endtime + " 止")//服务期限：
                        $("#main_sum").html(res.data.main_sum)//标准服务费合计(元)
                        $("#main_sumdiscount").html(res.data.main_sumdiscount)//折扣
                        $("#main_free").html(res.data.main_free)//应缴服务费(元)
                        if (res.data.gs_type == 2) {
                            var nr = '<img style="width:50px;margin-right:5px" src="/static_gs/logo.png" title="1641541697419545.png" alt="图片1.png"><?php  echo model("Constants")->gs[2];?>';
                            $("#logos").html(nr)
                            console.log(123)
                        } else if (res.data.gs_type == 3) {
                            var nr = '<img style="width:50px;margin-right:5px" src="/static_new/logo.png" title="1641541697419545.png" alt="图片1.png"><?php  echo model("Constants")->gs[3];?>';
                            $("#logos").html(nr)
                            console.log(123)
                        } else if (res.data.gs_type == 4) {
                            var nr = '<img style="width:50px;margin-right:5px" src="/static_tb/logo.png" title="1641541697419545.png" alt="图片1.png"><?php  echo model("Constants")->gs[4];?>';
                            $("#logos").html(nr)
                            console.log(123)
                        } else if (res.data.gs_type == 5) {
                            var nr = '<img style="width:50px;margin-right:5px" src="/static_gs_hn/logo.png" title="1641541697419545.png" alt="图片1.png"><?php  echo model("Constants")->gs[5];?>';
                            $("#logos").html(nr)
                            console.log(123)
                        } else if (res.data.gs_type == 6) {
                            var nr = '<img style="width:50px;margin-right:5px" src="/static_anxing/logo.png" title="1641541697419545.png" alt="图片1.png"><?php  echo model("Constants")->gs[6];?>';
                            $("#logos").html(nr)
                            console.log(123)
                        } else if (res.data.gs_type == 7) {
                            var nr = '<img style="width:50px;margin-right:5px" src="/static_dadi/logo.png" title="1641541697419545.png" alt="图片1.png"><?php  echo model("Constants")->gs[6];?>';
                            $("#logos").html(nr)
                            console.log(123)
                        } else {
                            var nr = '<img style="width:50px;margin-right:5px" src="/static/logo.png" title="1641541697419545.png" alt="图片1.png"><?php  echo model("Constants")->gs[1];?>';
                            console.log(345)
                            $("#logos").html(nr)
                        }
                        //服务项目
                        var tongchou = `<tr style="background: rgba(190, 227, 255, 0.94)">
            							<td style="color:#000;text-align: left">服务项目</td>
            							<td style="border-left: 1px solid #fff;color:#000">服务责任限额</td>
            							<td style="border-left: 1px solid #fff;color:#000">标准服务费</td>
            							<td style="border-left: 1px solid #fff;color:#000">折后服务费</td>
            						</tr>`
                        //机动车损失服务
                        if (res.data.main_name == 1) {
                            tongchou += `<tr>
            							<td style="text-align:left;color:#000">机动车车损</td>
            							<td style="border-left: 1px solid #fff;">` + res.data.main_money + `</td>
            							<td style="border-left: 1px solid #fff;">` + res.data.main_standard + `</td>
                                        <td style="border-left: 1px solid #fff;" class="zong_tongchou">` + (res.data.main_standard * res.data.main_sumdiscount / 100).toFixed(2) + `</td>
            						</tr>`
                        }
                        //机动车第三者责任服务
                        if (res.data.main_disan == 1) {
                            tongchou += `<tr>
										<td style="text-align:left;color:#000">机动车第三者责任</td>
										<td style="border-left: 1px solid #fff;">` + res.data.main_santong + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.main_biao + `</td>
                                        <td style="border-left: 1px solid #fff;" class="zong_tongchou">` + (res.data.main_biao * res.data.main_sumdiscount / 100).toFixed(2) + `</td>
									</tr>`
                        }

                        //车上人员责任服务(司机)
                        if (res.data.siji == 1) {
                            tongchou += `<tr>
										<td style="text-align:left;color:#000">车上人员责任(司机)</td>
										<td style="border-left: 1px solid #fff;">` + res.data.siji_tong + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.siji_biao + `</td>
                                        <td style="border-left: 1px solid #fff;" class="zong_tongchou">` + (res.data.siji_biao * res.data.main_sumdiscount / 100).toFixed(2) + `</td>
									</tr>`
                        }
                        //车上人员责任保险(乘客)
                        console.log(res.data.ck_money)
                        if (res.data.chengke == 1) {
                            tongchou += `<tr>
										<td style="text-align:left;color:#000">车上人员责任(乘客)</td>
										<td style="border-left: 1px solid #fff;">` + res.data.ck_money + '*' + res.data.chengke_zuo + `</td>
										<td style="border-left:1px solid #fff;">` + res.data.ck_biao + `</td>
                                        <td style="border-left: 1px solid #fff;border-bottom: 1px solid #fff;" class="zong_tongchou">` + (res.data.ck_biao * res.data.main_sumdiscount / 100).toFixed(2) + `</td>
									</tr>`
                        }
                        //自燃损失服务
                        if (res.data.dianwang == 1) {
                            tongchou += `<tr>
										<td style="text-align:left;color:#000">外部电网故障损失</td>
										<td style="border-left: 1px solid #fff;">` + res.data.dw_tong + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.dw_biao + `</td>
                                        <td style="border-left: 1px solid #fff;" class="zong_tongchou">` + res.data.dw_ying + `</td>
									</tr>`
                        }
                        //三者医保外用药
                        if (res.data.dao_name == 1) {
                            tongchou += `
            						<tr>
										<td style="text-align:left;color:#000">医保外用药</td>
										<td style="border-left:1px solid #fff;">` + res.data.dao_tong + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.dao_biao + `</td>
										<td style="border-left:1px solid #fff;border-bottom:1px solid #fff;" class="zong_tongchou">` + res.data.dao_biao + `</td>
									</tr>`
                        }
                        //自燃损失服务
                        if (res.data.ziran == 1) {
                            tongchou +=
                                `<tr>
										<td style="text-align:left;color:#000"> `+ res.data.ziran_c + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.zi_tong + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.zi_biao + `</td>
										<td style="border-left: 1px solid #fff;border-bottom:1px solid #fff;" class="zong_tongchou">` + res.data.zi_ying + `</td>
									</tr>`
                        }
                        //发动机涉水损失服务
                        if (res.data.fdjsunshi == 1) {
                            tongchou +=
                                `<tr>
										<td style="text-align:left;color:#000"> `+ res.data.fd_c + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.fdj_tong + `</td>
										<td style="border-left:1px solid #fff;">` + res.data.fdj_biao + `</td>
										<td style="border-left: 1px solid #fff;border-bottom:1px solid #fff;" class="zong_tongchou">` + res.data.fdj_ying + `</td>
									</tr>`
                        }
                        console.log(res.data.fdjsunshi);
                        //指定修理厂服务
                        if (res.data.zdxiuli == 1) {
                            tongchou +=
                                `<tr>
										<td style="text-align:left;color:#000"> `+ res.data.zd_c + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.zd_tong + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.zd_biao + `</td>
										<td style="border-left: 1px solid #fff;border-bottom:1px solid #fff;" class="zong_tongchou">` + res.data.zd_ying + `</td>
									</tr>`
                        }
                        //车上货物责任服务
                        if (res.data.huowu == 1) {
                            tongchou +=
                                `<tr>
										<td style="text-align:left;color:#000"> `+ res.data.huowu_c + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.hw_tong + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.hw_biao + `</td>
										<td style="border-left:1px solid #fff;border-bottom:1px solid #fff;" class="zong_tongchou">` + res.data.hw_ying + `</td>
									</tr>`
                        }
                        //玻璃单独破碎服务
                        if (res.data.boli == 1) {
                            tongchou +=
                                `<tr>
										<td style="text-align:left;color:#000"> `+ res.data.boli_c + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.bl_tong + `</td>
										<td style="border-left: 1px solid #fff;">` + res.data.bl_biao + `</td>
										<td style="border-left: 1px solid #fff;border-bottom:1px solid #fff;" class="zong_tongchou">` + res.data.bl_ying + `</td>
									</tr>`
                        }
                        //不计免赔服务
                        if (res.data.buji == 1) {
                            tongchou += `<tr>
										<td style="text-align:left;color:#000">不计免赔服务</td>
										<td style="border-left: 1px solid #fff;">` + res.data.bu_tong + `</td>
										<td style="border-left:1px solid #fff;">` + res.data.bu_biao + `</td>
									</tr>`
                        }
                        // 	标准服务费（标准服务费合计-医保外用药标准服务费）
                        // 折后服务费（折后服务费：=应缴服务费 -dao_ying）
                        tongchou += `<tr>
									<td colspan="2" style="text-align:left;color:#000">应缴服务费(元)：</td>

									<td colspan="1" style="border-left: 1px solid #fff;"><p ">` + res.data.main_sum + `</p></td>
									<td colspan="1" style="border-left: 1px solid #fff;color:red;"><p class="shangyefei"">` + res.data.main_free + `</p></td>
								</tr>`

                        if (!res.data.jq_price) {
                            var jq_price = 0.00
                        } else {
                            var jq_price = res.data.jq_price
                        }
                        if (!res.data.cc_price) {
                            var cc_price = 0.00
                        } else {
                            var cc_price = res.data.cc_price
                        }
                        var num11 = numAdd(jq_price, cc_price)

                        var hejii = numAdd(num11, zong)
                        var hejii = hejii.toFixed(2)
                        tongchou += `<tr>
										<td colspan="2" style="text-align:left;color:#000">折扣系数</td>
										<td colspan="2" style="border-left: 1px solid #fff;">` + res.data.main_sumdiscount / 100 + `</td>
									</tr>`

                        tongchou += `<tr>
										<td style="text-align:left;color:#000">交强险：` + jq_price + `</td>
										<td style="border-left: 1px solid #fff;color:#000">车船税：` + cc_price + `</td>
										<td colspan="2" style="border-left:1px solid #fff;color:#000">合计：<span class="hejii"">` + hejii + `</span></td>
									</tr>`
                        tongchou += `<tr>
									<td style="text-align:left;color:#000">备注</td>
									<td colspan="3" style="border-left: 1px solid #fff;color:#2796FF;text-align:left">此报价优惠，仅限当日有效，最终价格以审核为准</td>
								</tr>`
                        $("#bjrq").html(res.data.yw_join_time)
                        $("#bjr").html(res.data.yw_belonger)
                        $("#xiangmu").html(tongchou)

                        //总服务费（合计）
                        var zong_tongchou = $('.zong_tongchou');//找到div里面所有的input
                        var ztc = 0;
                        for (var i = 0; i < zong_tongchou.length; i++) {
                            ztc += +Number(zong_tongchou[i].textContent);
                        }
                        ztc += +Number(res.data.bu_biao * res.data.main_sumdiscount / 100);
                        var zong = ztc.toFixed(2)
                        $('.shangyefei').text(ztc.toFixed(2));

                        var hejii = numAdd(num11, zong)
                        var hejii = hejii.toFixed(2)
                        $('.hejii').text(hejii);

                    }
                })
                $('#myModal1').modal();
            }

            $("#anni").on("click", function () {
                doPrint()
            })

            function doPrint() {
                var printContents = $("#baojiadann").html();
                var w = window.open('', '_blank');
                w.document.write(printContents);
                w.document.write(`<style>
    .kuang {
        border: 2px solid #000;
        min-width: 800px;
        color: #000;
        font-weight: bold;
    }

    .kuang .titlee {
        height: 60px;
        line-height: 55px;
        text-align: center;
        font-size: 25px;
        font-weight: bold;
        border-bottom: 2px solid #000;
    }

    .kk {
        line-height: 30px;
        padding: 10px 0;
        font-size: 16px;
    }

    .kuang_xinxi {
        display: flex;
        justify-content: space-between;
        margin: 0 auto;
        border: 1px solid;
        border-top: 0;
    }

    .leftborder {
        border-left: 1px solid;
    }

    .textleft {
        text-align: left;
    }

    .kuang_list {
        display: flex;
        color: #333;
        font-size: 15px;
        font-weight: 500;
    }

    .list_tit {
        width: 130px;
        text-align: left;
        border-right: 1px solid #fff;
        box-sizing: border-box;
        padding-left: 20px;
        color: #000;
    }

    .list_cont {
        width: 300px;
        padding-left: 10px;
        box-sizing: border-box;
    }

    .table1 {
        border-top: 1px solid #fff;
        border-bottom: 1px solid #fff;
        width: 100%;
        border-collapse: collapse;
        font-size: 15px;
        color: #333;
        font-weight: 500;
    }

    .table1 tr:nth-child(odd) {
        background: rgba(241, 243, 245, 0.42);
    }

    .table1 tr:nth-child(even) {
        background: rgba(255, 255, 255, 0.42);
    }

    .table1 td {
        border-top: 1px solid #fff;
        /*border-top: 2px solid #000;*/
        padding: 0 10px;
        height: 35px;
        line-height: 35px;
        box-sizing: border-box;
        width: 20%;
        text-align: center;
    }

    .heji {
        height: 35px;
        line-height: 35px;
        text-align: center;
        font-size: 18px;
        font-weight: bold;
    }

    .table2 {
        font-weight: bold;
        text-align: center;
        border-bottom: 0px;
    }

    .beizhu {
        padding-left: 10px;
        padding-top: 10px;
        padding-bottom: 20px;
    }

    .beizhu_cont p {
        line-height: 25px;
        margin: 0;
        text-indent: 25px
    }
     .kuang_xinxi {
        border: 1px solid #fff;
        border-top: 0;
    }

    .list_tit {
        text-align: left;
        border-right: 1px solid #fff;
        box-sizing: border-box;
        padding-left: 20px;
    }

    .list_cont {
        padding-left: 10px;
        box-sizing: border-box;
    }

    .leftborder {
        border-left: 1px solid #fff;
    }
    
    .textleft {
        text-align: left;
    }
    </style>`)
                w.document.close();
                w.focus();
                w.print();
                w.close();
            }

            // 加法
            function numAdd(num1, num2) {
                var baseNum, baseNum1, baseNum2;
                try {
                    baseNum1 = num1.toString().split(".")[1].length;
                } catch (e) {
                    baseNum1 = 0;
                }
                try {
                    baseNum2 = num2.toString().split(".")[1].length;
                } catch (e) {
                    baseNum2 = 0;
                }
                baseNum = Math.pow(10, Math.max(baseNum1, baseNum2));
                return (num1 * baseNum + num2 * baseNum) / baseNum;
            };
            function jiaofei(id) {
                var data = {'id': id}
                $.ajax({
                    url: "lists/one/jiaofei",
                    dataType: 'json',
                    type: 'post',
                    data: data,
                    success: function (res) {
                        var html = '<div class="tabqie onee active" data-tcf="shangchuan">上传图片</div>';
                        var zhifu = res.data;
                        for (var i=0;i<zhifu.length;i++){
                            html+=`<div class="tabqie three" data-tcf="tcf" data-id="`+zhifu[i].id+`">`+zhifu[i].name+`</div>`;
                        }
                        $('#new_qiehuan').html(html);
                    }
                })
            }
            function newjiaofei(id, type, gs_type) {
                console.log(gs_type)
                $(".onee").addClass("active");
                $(".three").removeClass("active")
                $("#new_jiaofei_id").val(id)
                $("#shangchuan").hide()
                var data = {'id': id, 'type': 'shangchuan'}
                $(".gshn").show()
                $("#myModal_newjiaofei .modal-dialog").css("width", "1070px")
                $.ajax({
                    url: "lists/one/new_baojiadan",
                    dataType: 'json',
                    type: 'post',
                    data: data,
                    success: function (res) {
                        if (res.data.chezhu == 2) {
                            $("#bb").attr('checked', 'true');
                            $(".namee").html('车主姓名:')
                            $("#newjiao_name").html(res.data.car_owner)//车主姓名
                        } else {
                            $("#aa").attr('checked', 'true');
                            $(".namee").html('被服务人')
                            $("#newjiao_name").html(res.data.learned_name)//车主姓名
                        }
                        if (res.data.tcxm == 2) {
                            $("input[name='newxiangmu1']").prop("checked", true);
                        } else {
                            $("input[name='newxiangmu1']").prop("checked", false);
                        }
                        if (res.data.tk_type == 1) {
                            $("input[name='newtiaokuan']").prop("checked", true);
                        } else {
                            $("input[name='newtiaokuan']").prop("checked", false);
                        }
                        if (res.data.bjt == 1) {
                            $("input[name='beijingtu']").prop("checked", true);
                        } else {
                            $("input[name='beijingtu']").prop("checked", false);
                        }
                        var vall = res.data.er
                        $("#newerweimak").show()
                        $("#newerweima").html("<img src=" + vall + " style='width:160px;height:160px;'/>")
                        $(".new_zhifu_timess").show()
                        $("#new_zhifu_times").html(res.data.times)
                        $("#new_qiehuan").css("display", 'flex')
                        $("#newjiao_pai").html(res.data.car_num)//车牌号码
                        $("#newjiao_jia").html(res.data.car_vin)//车架号
                        $("#newjiao_money").html(res.data.main_free)//订单金额
                        $("#newjiao_bianhao").html(res.data.tong_storage)//编号
                        var tongchou = ''
                        if (res.data.main_name == 1) {
                            tongchou +=
                                `<div class="new_cont_list_li">
                                        <div class="tt">机动车车损损失</div>
                                        <div class="tt">` + res.data.main_standard + `</div>
                                        <div class="ed">额度:` + res.data.main_money + `</div>
                                    </div>`
                        }
                        //机动车第三者责任服务
                        if (res.data.main_santong == 3000000) {
                            var main_santong = '300万'
                        } else if (res.data.main_santong == 2000000) {
                            var main_santong = '200万'
                        } else if (res.data.main_santong == 1500000) {
                            var main_santong = '150万'
                        } else if (res.data.main_santong == 1000000) {
                            var main_santong = '100万'
                        } else if (res.data.main_santong == 500000) {
                            var main_santong = '50万'
                        } else if (res.data.main_santong == 300000) {
                            var main_santong = '30万'
                        } else if (res.data.main_santong == 200000) {
                            var main_santong = '20万'
                        } else if (res.data.main_santong == 100000) {
                            var main_santong = '10万'
                        } else if (res.data.main_santong == 50000) {
                            var main_santong = '5万'
                        }
                        if (res.data.main_disan == 1) {
                            tongchou +=
                                `<div class="new_cont_list_li">
                                        <div class="tt">机动车第三者责任</div>
                                        <div class="tt">` + res.data.main_biao + `</div>
                                        <div class="ed">额度:` + main_santong + `</div>
                                    </div>`
                        }

                        //车上人员责任服务(司机)
                        if (res.data.siji == 1) {
                            tongchou +=
                                `<div class="new_cont_list_li">
                                        <div class="tt">机动车车上人员-司机</div>
                                        <div class="tt">` + res.data.siji_biao + `</div>
                                        <div class="ed">额度:` + res.data.siji_tong + `</div>
                                    </div>`
                        }
                        //车上人员责任保险(乘客)
                        if (res.data.ck_money == 10000) {
                            var ck_money = '1万'
                        } else if (res.data.ck_money == 20000) {
                            var ck_money = '2万'
                        } else if (res.data.ck_money == 30000) {
                            var ck_money = '3万'
                        } else if (res.data.ck_money == 40000) {
                            var ck_money = '4万'
                        } else if (res.data.ck_money == 50000) {
                            var ck_money = '5万'
                        } else if (res.data.ck_money == 60000) {
                            var ck_money = '6万'
                        } else if (res.data.ck_money == 70000) {
                            var ck_money = '7万'
                        } else if (res.data.ck_money == 80000) {
                            var ck_money = '8万'
                        } else if (res.data.ck_money == 90000) {
                            var ck_money = '9万'
                        } else if (res.data.ck_money == 100000) {
                            var ck_money = '10万'
                        } else if (res.data.ck_money == 200000) {
                            var ck_money = '20万'
                        }
                        if (res.data.chengke == 1) {
                            console.log('ck_tong', res.data)
                            tongchou +=
                                `<div class="new_cont_list_li">
                                        <div class="tt">机动车车上人员-乘客` + ck_money + `元/座` + res.data.chengke_zuo + `座</div>
                                        <div class="tt">` + res.data.ck_biao + `</div>
                                        <div class="ed">额度:` + res.data.ck_money + `*`+res.data.chengke_zuo+`座</div>
                                    </div>`
                        }

                        //外部电网故障损失险
                        if (res.data.dianwang == 1) {
                            tongchou +=
                                `<div class="new_cont_list_li">
                                        <div class="tt">外部电网故障损失险</div>
                                        <div class="tt">` + res.data.dw_biao + `</div>
                                        <div class="ed">额度:` + res.data.dw_tong + `</div>
                                    </div>`
                        }
                        //三者医保外用药
                        if (res.data.dao_name == 1) {
                            tongchou +=
                                `<div class="new_cont_list_li">
                    						<div class="tt">医保外用药</div>
                    						<div class="tt">` + res.data.dao_biao + `</div>
                    						<div class="ed">额度:` + res.data.dao_tong + `</div>
                    					</div>`
                        }
                        //自燃损失服务
                        if (res.data.ziran == 1) {
                            // 		tongchou += `<tr>
                            // 						<td>自燃损失服务</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.zi_tong+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.zi_biao+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.zi_zhe+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.zi_ying+`</td>
                            // 					</tr>`
                            tongchou +=
                                //          `<tr>
                                // 		<td>`+res.res.ziran_c+`</td>
                                // 		<td style="border-left: 2px solid #000;">`+res.res.zi_tong+`</td>
                                // 		<td style="border-left: 2px solid #000;">`+res.res.zi_biao+`</td>
                                // 	</tr>`
                                `<div class="new_cont_list_li">
                    						<div class="tt">` + res.data.ziran_c + `</div>
                    						<div class="tt">` + res.data.zi_biao + `</div>
                    						<div class="ed">额度:` + res.data.zi_tong + `</div>
                    					</div>`
                        }
                        //发动机涉水损失服务
                        if (res.data.fdjsunshi == 1) {
                            // 		tongchou += `<tr>
                            // 						<td>发动机涉水损失服务</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.fdj_tong+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.fdj_biao+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.fdj_zhe+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.fdj_ying+`</td>
                            // 					</tr>`
                            tongchou +=
                                //          `<tr>
                                // 		<td>`+res.res.fd_c+`</td>
                                // 		<td style="border-left: 2px solid #000;">`+res.res.fdj_tong+`</td>
                                // 		<td style="border-left: 2px solid #000;">`+res.res.fdj_biao+`</td>
                                // 	</tr>`
                                `<div class="new_cont_list_li">
                    						<div class="tt">` + res.data.fd_c + `</div>
                    						<div class="tt">` + res.data.fdj_biao + `</div>
                    						<div class="ed">额度:` + res.data.fdj_tong + `</div>
                    					</div>`
                        }
                        //指定修理厂服务
                        if (res.data.zdxiuli == 1) {
                            // 		tongchou += `<tr>
                            // 						<td>指定修理厂服务</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.zd_tong+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.zd_biao+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.zd_zhe+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.zd_ying+`</td>
                            // 					</tr>`
                            tongchou +=
                                //          `<tr>
                                // 		<td>`+res.res.zd_c+`</td>
                                // 		<td style="border-left: 2px solid #000;">`+res.res.zd_tong+`</td>
                                // 		<td style="border-left: 2px solid #000;">`+res.res.zd_biao+`</td>
                                // 	</tr>`
                                `<div class="new_cont_list_li">
                    						<div class="tt">` + res.data.zd_c + `</div>
                    						<div class="tt">` + res.data.zd_biao + `</div>
                    						<div class="ed">额度:` + res.data.zd_tong + `</div>
                    					</div>`
                        }
                        //车上货物责任服务
                        if (res.data.huowu == 1) {
                            // 		tongchou += `<tr>
                            // 						<td>车上货物责任服务</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.hw_tong+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.hw_biao+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.hw_zhe+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.hw_ying+`</td>
                            // 					</tr>`
                            tongchou +=
                                //          `<tr>
                                // 		<td>`+res.res.huowu_c+`</td>
                                // 		<td style="border-left: 2px solid #000;">`+res.res.hw_tong+`</td>
                                // 		<td style="border-left: 2px solid #000;">`+res.res.hw_biao+`</td>
                                // 	</tr>`
                                `<div class="new_cont_list_li">
                    						<div class="tt">` + res.data.huowu_c + `</div>
                    						<div class="tt">` + res.data.hw_biao + `</div>
                    						<div class="ed">额度:` + res.data.hw_tong + `</div>
                    					</div>`
                        }
                        //玻璃单独破碎服务
                        if (res.data.boli == 1) {
                            // 		tongchou += `<tr>
                            // 						<td>玻璃单独破碎服务</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.bl_tong+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.bl_biao+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.bl_zhe+`</td>
                            // 						<td style="border-left: 1px solid #000;">`+res.res.bl_ying+`</td>
                            // 					</tr>`
                            tongchou +=
                                //          `<tr>
                                // 		<td>`+res.res.boli_c+`</td>
                                // 		<td style="border-left: 2px solid #000;">`+res.res.bl_tong+`</td>
                                // 		<td style="border-left: 2px solid #000;">`+res.res.bl_biao+`</td>
                                // 	</tr>`
                                `<div class="new_cont_list_li">
                    						<div class="tt">` + res.data.boli_c + `</div>
                    						<div class="tt">` + res.data.bl_biao + `</div>
                    						<div class="ed">额度:` + res.data.bl_tong + `</div>
                    					</div>`
                        }
                        $("#fuwuxm").html(tongchou)
                        if (res.data.status == 5) {

                            if (!res.data.jiaofei_time == '') {
                                if (res.data.new_zf) {
                                    var type = '扫码'
                                    $("#jiao_bianhao").html(res.data.new_zf.req_seq_id)//编号
                                } else {
                                    if (res.data.jiaofei_type == 1) {
                                        var type = '微信'
                                    } else {
                                        var type = '支付宝'
                                    }
                                    $("#jiao_bianhao").html(res.data.tong_storage)//编号
                                }
                                $("#newjiaofei_fangshi").html(type)//支付方式
                                $("#newjiaofei_time").html(res.data.jiaofei_time)//支付时间
                            } else {
                                $("#newjiaofei_fangshi").html('其他')//支付方式
                                $("#newjiaofei_time").html('')//支付时间
                            }
                            $(".new_table").hide()
                            $("#newjiaofei_success").show()
                            $("#newerweima").hide()
                            $("#newerweimak").hide()
                            $(".new_zhifu_timess").hide()
                            $("#new_qiehuan").hide()
                        } else {
                            $("#newjiaofei_success").hide()
                            $(".new_table").show()
                            // $("#newerweima").show()
                            // $("#newerweimak").show()
                            // $(".new_zhifu_timess").show()
                            // $("#new_zhifu_times").html(res.data.times)
                            $("#new_qiehuan").css("display", 'flex')


                            $("#newerweimak").hide()
                            $("#newerweima").html('')
                            $("#shangchuan").show()
                            $("#xuanzetu_btn").show()
                        }
                        $('#myModal_newjiaofei').modal();
                    }
                })
            }

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        recyclebin: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    'dragsort_url': ''
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: 'lists/one/recyclebin' + location.search,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {
                            field: 'deletetime',
                            title: __('Deletetime'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'operate',
                            width: '140px',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'Restore',
                                    text: __('Restore'),
                                    classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
                                    icon: 'fa fa-rotate-left',
                                    url: 'lists/one/restore',
                                    refresh: true
                                },
                                {
                                    name: 'Destroy',
                                    text: __('Destroy'),
                                    classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
                                    icon: 'fa fa-times',
                                    url: 'lists/one/destroy',
                                    refresh: true
                                }
                            ],
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        baoan: function () {
            $(".btn-add").data("area", ["100%", "100%"]); //添加
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'lists/one/baoan' + location.search,
                    table: 'baoan',
                }
            });

            var table = $("#table");
            table.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                //这里我们手动设置底部的值
                $("#buchang_money").text(data.buchang_money);
                $("#weijue_money").text(data.weijue_money);
            });
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                searchFormTemplate: 'baoan',
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        // {field: 'gs_type', title: __('Gs_type'),operate: false},
                        {field: 'baoan_id', title: __('报案单号'), operate: 'LIKE'},
                        {
                            field: 'baoan_time',
                            title: __('报案时间'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'chuxian_time',
                            title: __('出险时间'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },
                        {field: 'phone', title: __('联系电话'),operate: false},
                        {field: 'tong_number', title: __('服务单号'), operate: 'LIKE'},
                        {field: 'car_num', title: __('车牌号'), operate: 'LIKE'},
                        {field: 'car_vin', title: __('车架号'), operate: 'LIKE'},
                        {field: 'learned_name', title: __('被服务人'), operate: 'LIKE'},
                        {
                            field: 'yw_hetong_time',
                            title: __('核统日期'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime,datetimeFormat: "YYYY-MM-DD"
                        },
                        {
                            field: 'plan_endtime',
                            title: __('服务止期'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime,datetimeFormat: "YYYY-MM-DD"
                        },
                        {field: 'chakan_ren', title: __('查勘人'), operate: 'LIKE'},
                        {field: 'buchang_money', title: __('补偿金额'), operate: false},
                        {field: 'baoan_status', title: __('案件状态'),
                            searchList: {
                                0: __('未结案'),
                                1: __('已结案'),
                            },formatter: Table.api.formatter.label
                        },
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate,
                            buttons: [
                                {
                                    name: 'details',
                                    text: '浏览',
                                    classname: 'btn btn-info btn-xs btn-dialog',
                                    icon: '',
                                    url: 'lists/one/baoan_details',
                                    extend: 'data-area=["100%","100%"]',
                                    visible: function (row) {
                                        //返回true时按钮显示,返回false隐藏
                                        return true;
                                    }
                                }
                            ]
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            //开始时间选择后
            $("#c-plan_strattime").on("dp.change", function (e) {
                var time = $("#c-plan_strattime").val()
                gettimee(time)
                var end_time = $("#c-plan_endtime").val()
                var tianshu = diy_time(time, end_time)
                $("#datecount").html(tianshu)
            })
            //结束时间选择后
            $("#c-plan_endtime").on("dp.change", function () {
                var time = $("#c-plan_strattime").val()
                var end_time = $("#c-plan_endtime").val()
                var tianshu = diy_time(time, end_time)
                $("#datecount").html(tianshu)
            })
            $(document).on("change", ".yw_classs", function(){
                //后续操作
                var yw_class = $('#yw_class').val();
                console.log('yw_class',yw_class)
                $.ajax({
                    url: "zuzhi/getUser",
                    type: 'post',
                    dataType: 'json',
                    data: {yw_class: yw_class},
                    success: function (ret) {
                        var data = ret.data; //将回调数据拆分成json数组
                        var expressCity = $("#guishu");
                        expressCity.empty(); //清空select
                        var str = '<option value="">请选择归属人</option>';
                        for (var i = 0; i < data.length; i++) {
                            str += '<option value="' + data[i].number + '">' + data[i].username + '('+data[i].number + ')</option>';
                        }
                        expressCity.append(str); //将str添加至select中
                    }, error: function (e) {
                        Backend.api.toastr.error(e.message);
                    }
                });

            });
            Controller.api.bindevent();
        },
        edit: function () {
            //开始时间选择后
            $("#c-plan_strattime").on("dp.change", function (e) {
                var time = $("#c-plan_strattime").val()
                gettimee(time)
                var end_time = $("#c-plan_endtime").val()
                var tianshu = diy_time(time, end_time)
                $("#datecount").html(tianshu)
            })
            //结束时间选择后
            $("#c-plan_endtime").on("dp.change", function () {
                var time = $("#c-plan_strattime").val()
                var end_time = $("#c-plan_endtime").val()
                var tianshu = diy_time(time, end_time)
                $("#datecount").html(tianshu)
            })
            Controller.api.bindevent();
        },
        details: function () {
            //开始时间选择后
            $("#c-plan_strattime").on("dp.change", function (e) {
                var time = $("#c-plan_strattime").val()
                // gettimee(time)
                var end_time = $("#c-plan_endtime").val()
                var tianshu = diy_time(time, end_time)
                $("#datecount").html(tianshu)
            })
            //结束时间选择后
            $("#c-plan_endtime").on("dp.change", function () {
                var time = $("#c-plan_strattime").val()
                var end_time = $("#c-plan_endtime").val()
                var tianshu = diy_time(time, end_time)
                $("#datecount").html(tianshu)
            })
            Controller.api.bindevent();
        },
        bulu: function () {
            Controller.api.bindevent();
        },
        xubao: function () {
            //开始时间选择后
            $("#c-plan_strattime").on("dp.change", function (e) {
                var time = $("#c-plan_strattime").val()
                gettimee(time)
                var end_time = $("#c-plan_endtime").val()
                var tianshu = diy_time(time, end_time)
                $("#datecount").html(tianshu)
            })
            //结束时间选择后
            $("#c-plan_endtime").on("dp.change", function () {
                var time = $("#c-plan_strattime").val()
                var end_time = $("#c-plan_endtime").val()
                var tianshu = diy_time(time, end_time)
                $("#datecount").html(tianshu)
            })
            Controller.api.bindevent();
        },
        kaipiao: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"), null, null, function () {
                    if ($("#treeview").length > 0) {
                        var r = $("#treeview").jstree("get_all_checked");
                        $("input[name='row[rules]']").val(r.join(','));
                    }
                    return true;
                });
                // $(document).on("change", "select[name='row[yw_come]']", function () {
                //     var yw_come = $(this).data("yw_come");
                //     console.log('+++++++++++++++++',yw_come)
                //     var id = $(this).data("id");
                //     if ($(this).val() == id) {
                //         $("option[value='" + yw_come + "']", this).prop("selected", true).change();
                //         Backend.api.toastr.error(__('Can not change the parent to self'));
                //         return false;
                //     }
                //     $.ajax({
                //         url: "zuzhi/getselect",
                //         type: 'post',
                //         dataType: 'json',
                //         data: {id: id, yw_come: $(this).val()},
                //         success: function (ret) {
                //             var data = ret.data; //将回调数据拆分成json数组
                //             var arr = []
                //             for (let i in data) {
                //                 // arr.push(data[i]); //属性
                //                 arr.push({
                //                     id:i,
                //                     name:data[i]
                //                 })
                //                 //arr.push(obj[i]); //值
                //             }
                //             var expressCity = $("#yw_class");
                //             expressCity.empty(); //清空select
                //             var str = '<option value="">请选择所属部门</option>';
                //             for (var i = 0; i < arr.length; i++) {
                //                 str += '<option value="' + data[i].id + '">' + data[i].name + '</option>';
                //             }
                //             expressCity.append(str); //将str添加至select中
                //         }, error: function (e) {
                //             Backend.api.toastr.error(e.message);
                //         }
                //     });
                // });
            },
        }
    };

    function diy_time(time1, time2) {
        time1 = Date.parse(new Date(time1));
        time2 = Date.parse(new Date(time2));
        console.log('time1',time1)
        console.log('time2',time2)
        var num = (time2 - time1);
        if(num > 0){
            return time3 = Math.abs(parseInt( num / 1000 / 3600 / 24) + 1) + '天';
        }else{
            return time3 = '0天';
        }
    }

    function gettimee(date) {
        $.ajax({
            type: 'post',
            url: "/api/order/s_time", //发送路径
            data: {
                time: date
            }, //发送的数据
            //                    dataType: 'json',
            async: false, //是否异步
            success: function (data) {
                $("#c-plan_endtime").val(data.data)
            }
        })
    }
    $("#lishi").on("click", function (e) {
        var code=$("#c-car_vin").val()
        if(code==''){
            layer.alert("请输入车架号")
            return false;
        }
        layer.open({
            type: 2,
            title: '报案信息',
            maxmin: true,
            area: ['100%', '100%'],
            content: "/qdmbazItgX.php/lists/one/baoan?car_vin=" + code,
        });
    })

    return Controller;
});
